(function(app) {
    app
        .controller("content_29_healthBbrCtrl", ["$scope", "$state", "myFactory", '$stateParams', "$q", '$timeout', '$location', '$http', '$ionicHistory', function($scope, $state, myFactory, $stateParams, $q, $timeout, $location, $http, $ionicHistory) {

            //数组对象增加删除指定元素方法
            Array.prototype.removeArrByValue = function(val) {
                for (var i = 0; i < this.length; i++) {
                    if (this[i] == val) {
                        this.splice(i, 1);
                        break;
                    }
                }
            }

            //接收参数
            var itemId = $stateParams.itemId; //变更项目ID
            var chdrnum01 = $stateParams.chdrnum01; //保单号
            var chdrcoy = $stateParams.chdrcoy; //保单公司号码
            var item29 = $stateParams.item29;
            var lfAge = $stateParams.lfAge;
            var lfSex = $stateParams.lfSex;
            var token = sessionStorage.getItem("token");

            //增加对五岁儿童和女性显示或隐藏控制：
            if (lfAge < 5) {
                console.log("五岁以下儿童：" + lfAge);
                $("#newBornChildId_lf_15A").show();
                $("#newBornChildId_lf_15B").show();
            } else {
                console.log("非五岁以下儿童：" + lfAge);
                $("#newBornChildId_lf_15A").hide();
                $("#newBornChildId_lf_15B").hide();
            }
            if (lfSex == "F") {
                console.log("女性：" + lfSex);
                $("#female_lf_16A").show();
                $("#female_lf_16B").show();
            } else {
                console.log("男性：" + lfSex);
                $("#female_lf_16A").hide();
                $("#female_lf_16B").hide();
            }

            //var problemIdArr = [];
            //var problemIdStr=sessionStorage.getItem("problemIdArr_h_lf");//读取浏览器缓存数据
            $scope.data = {
                //9B正常异常
                h_lf_button_y_10b: false,
                h_lf_button_n_10b: false,
                radio_flag: {
                    /***************是否按钮标识：被保险人**************/
                    h_lf_flag_y_1: false,
                    h_lf_flag_y_2: false,
                    h_lf_flag_y_3: false,
                    h_lf_flag_y_4: false,
                    h_lf_flag_y_5: false,
                    h_lf_flag_y_6: false,
                    h_lf_flag_y_7: false,
                    h_lf_flag_y_8: false,
                    h_lf_flag_y_8a: false,
                    h_lf_flag_y_8b: false,
                    h_lf_flag_y_8c: false,
                    h_lf_flag_y_8d: false,
                    h_lf_flag_y_8e: false,
                    h_lf_flag_y_8f: false,
                    h_lf_flag_y_8g: false,
                    h_lf_flag_y_8h: false,
                    h_lf_flag_y_8i: false,
                    h_lf_flag_y_8j: false,
                    h_lf_flag_y_8k: false,
                    h_lf_flag_y_9: false,
                    h_lf_flag_y_10: false,
                    h_lf_flag_y_10a: false,
                    h_lf_flag_y_10b: false,
                    h_lf_flag_y_10c: false,
                    h_lf_flag_y_10d: false,
                    h_lf_flag_y_11: false,
                    h_lf_flag_y_12: false,
                    h_lf_flag_y_13: false,
                    h_lf_flag_y_14: false,
                    h_lf_flag_y_15: false,
                    h_lf_flag_y_15a: false,
                    h_lf_flag_y_15b: false,
                    h_lf_flag_y_16: false,
                    h_lf_flag_y_16a: false,
                    h_lf_flag_y_16b: false,

                    h_lf_flag_n_1: false,
                    h_lf_flag_n_2: false,
                    h_lf_flag_n_3: false,
                    h_lf_flag_n_4: false,
                    h_lf_flag_n_5: false,
                    h_lf_flag_n_6: false,
                    h_lf_flag_n_7: false,
                    h_lf_flag_n_8: false,
                    h_lf_flag_n_8a: false,
                    h_lf_flag_n_8b: false,
                    h_lf_flag_n_8c: false,
                    h_lf_flag_n_8d: false,
                    h_lf_flag_n_8e: false,
                    h_lf_flag_n_8f: false,
                    h_lf_flag_n_8g: false,
                    h_lf_flag_n_8h: false,
                    h_lf_flag_n_8i: false,
                    h_lf_flag_n_8j: false,
                    h_lf_flag_n_8k: false,
                    h_lf_flag_n_9: false,
                    h_lf_flag_n_10: false,
                    h_lf_flag_n_10a: false,
                    h_lf_flag_n_10b: false,
                    h_lf_flag_n_10c: false,
                    h_lf_flag_n_10d: false,
                    h_lf_flag_n_11: false,
                    h_lf_flag_n_12: false,
                    h_lf_flag_n_13: false,
                    h_lf_flag_n_14: false,
                    h_lf_flag_n_15: false,
                    h_lf_flag_n_15a: false,
                    h_lf_flag_n_15b: false,
                    h_lf_flag_n_16: false,
                    h_lf_flag_n_16a: false,
                    h_lf_flag_n_16b: false,

                    /***************答案显示标识：被保险人**************/
                    h_tb_lf_1: false,
                    h_tb_lf_2: false,
                    h_tb_lf_3: false,
                    h_tb_lf_4: false,
                    h_tb_lf_5: false,
                    h_tb_lf_6: false,
                    h_tb_lf_7: false,
                    h_tb_lf_8: false,
                    h_tb_lf_8a: false,
                    h_tb_lf_8b: false,
                    h_tb_lf_8c: false,
                    h_tb_lf_8d: false,
                    h_tb_lf_8e: false,
                    h_tb_lf_8f: false,
                    h_tb_lf_8g: false,
                    h_tb_lf_8h: false,
                    h_tb_lf_8i: false,
                    h_tb_lf_8j: false,
                    h_tb_lf_8k: false,
                    h_tb_lf_9: false,
                    h_tb_lf_10: false,
                    h_tb_lf_10a: false,
                    h_tb_lf_10b: false,
                    h_tb_lf_10c: false,
                    h_tb_lf_10d: false,
                    h_tb_lf_11: false,
                    h_tb_lf_12: false,
                    h_tb_lf_13: false,
                    h_tb_lf_14: false,
                    h_tb_lf_15: false,
                    h_tb_lf_15a: false,
                    h_tb_lf_15b: false,
                    h_tb_lf_16: false,
                    h_tb_lf_16a: false,
                    h_tb_lf_16b: false
                },
                wineType: [{
                        id: 1,
                        name: '啤酒'
                    },
                    {
                        id: 2,
                        name: '白酒'
                    },
                    {
                        id: 3,
                        name: '红酒'
                    },
                    {
                        id: 4,
                        name: '其他'
                    }
                ],
                wineSelected: [] //储存已经选择酒的id号
                    //wineSelected: null	//储存已经选择酒的id号
            };

            var timestamp = myFactory.getTimetamp();
            var sfis = "itemId-token-timestamp";
            var signStr = "itemId=" + itemId + "&token=" + token + "&timestamp=" + timestamp; //encodeURI(name)
            var sign = myFactory.hex(signStr);
            var itemData = "";
            myFactory.loadingShow(); //显示加载圈
            $http({
                method: 'GET',
                url: app.domain + 'input/saveContentItem29.action',
                params: { 'itemId': itemId, 'itemStr': item29, 'sign': sign, 'sfis': sfis, 'token': token, 'timestamp': timestamp }
            }).then(function successCallback(response) {
                if (response.data.success) {
                    itemData = response.data.data.itemData;
                    //$scope.itemData=response.data.data.itemData;
                    $scope.item29 = itemData.item29;
                    $scope.item29Notice = itemData.item29Notice;
                    $scope.item29_h = itemData;
                    lfAge = itemData.lfAge;
                    lfSex = itemData.lfSex;
                    //页面加载初始化值
                    //var answerKeyArray = new Array("2","3a","3b","4a","4b","4c","4d","4e","4f","4g","4h","4i","4j","4k","5a","5b","5c","6","7","8","9","10","11","12","13","14","15","16","17a","17b","18a","18b");
                    //var answerKeyArray = new Array("3b","4a","4b","4c","4d","4e","4f","4g","4h","4i","4j","4k","5a","5b","5c","6","7","8","9","10","11","12","13","14","15","17a","17b","18a","18b");
                    //var answerKeyArray = new Array("1","2","3","4","5","6","7","8a","8b","8c","8d","8e","8f","8g","8h","8i","8j","8k","9","10a","10b","10c","10d","11","12","13","14","15a","15b","16a","16b");
                    var answerKeyArray = new Array("2", "3", "4", "5", "6", "7", "8a", "8b", "8c", "8d", "8e", "8f", "8g", "8h", "8i", "8j", "8k", "9", "10a", "10b", "10c", "10d", "11", "12", "13", "14", "15a", "15b", "16a", "16b");

                    //var answerKeyArray = new Array("2",'3a');
                    var tbr = $scope.item29.roleFlag;
                    /*if( tbr=="Y"){

                    }else{
                    }*/
                    for (var i = 0; i < answerKeyArray.length; i++) {
                        //jQuery("#tbr_"+i).show();
                        var flagName = "h_lf_flag_" + answerKeyArray[i];
                        var flagNameY = "h_lf_flag_y_" + answerKeyArray[i];
                        var flagNameN = "h_lf_flag_n_" + answerKeyArray[i];
                        var valName = "h_tb_lf_" + answerKeyArray[i];
                        var lf_flag = $scope.item29_h[flagName];
                        if (lf_flag == 'N') {
                            $scope.data.radio_flag[flagNameY] = false;
                            $scope.data.radio_flag[flagNameN] = true;
                            $scope.data.radio_flag[valName] = false;
                        } else if (lf_flag == 'Y') {
                            $scope.data.radio_flag[flagNameY] = true;
                            $scope.data.radio_flag[flagNameN] = false;
                            $scope.data.radio_flag[valName] = true;
                        }

                    }

                    /******* 展示普通变更项数据 ***********/
                    //var generalProblemArray = new Array("2","3a","3b","4a","4b","4c","4d","4e","4f","4g","4h","4i","4j","4k","5a","5c","6","9","10","11","12","13","14","17b","18a");
                    //var generalProblemArray = new Array("3b","4a","4b","4c","4d","4e","4f","4g","4h","4i","4j","4k","5a","5c","6","9","10","11","12","13","14","17b","18a");
                    //var generalProblemArray = new Array("3","4","5","7a","7b","7c","7d","7e","7f","7g","7h","7i","7j","7k","8","9a","9c","9d","10","12","13","14b","15a");
                    var generalProblemArray = new Array("4", "5", "6", "8a", "8b", "8c", "8d", "8e", "8f", "8g", "8h", "8i", "8j", "8k", "9", "10a", "10c", "10d", "11", "12", "13", "14", "15b", "16a");

                    var h_lf_flag_general = "";
                    for (var i = 0; i < generalProblemArray.length; i++) {
                        h_lf_flag_general = $scope.item29_h["h_lf_flag_" + generalProblemArray[i]]
                        if (h_lf_flag_general == 'Y') {
                            $("#h_lf_flag_y_" + generalProblemArray[i]).slideDown();
                            $("#generalRemark_" + "lf" + "_" + generalProblemArray[i]).val($scope.item29_h["h_lf_" + generalProblemArray[i]]);
                        }
                    }

                    /******* 展示特殊变更项数据 ***********/
                    var h_lf_flag_10b = $scope.item29_h.h_lf_flag_10b;
                    if (h_lf_flag_10b == 'Y') {
                        $("#h_lf_flag_y_10b").slideDown();
                        showContent10b();
                    }
                    var h_lf_flag_2 = $scope.item29_h.h_lf_flag_2;
                    if (h_lf_flag_2 == 'Y') {
                        $("#h_lf_flag_y_2").slideDown();
                        showContent2();
                    }

                    var h_lf_flag_3 = $scope.item29_h.h_lf_flag_3;
                    if (h_lf_flag_3 == 'Y') {
                        $("#h_lf_flag_y_3").slideDown();
                        showContent3();
                    }

                    var h_lf_flag_7 = $scope.item29_h.h_lf_flag_7;
                    if (h_lf_flag_7 == 'Y') {
                        $("#h_lf_flag_y_7").slideDown();
                        showContent7();
                    }

                    var h_lf_flag_12 = $scope.item29_h.h_lf_flag_12;
                    if (h_lf_flag_12 == 'Y') {
                        $("#h_lf_flag_y_12").slideDown();
                        showContent12();
                    }

                    //	显示第16题信息-没有了
                    /*var h_lf_flag_16=$scope.item23_h.h_lf_flag_16;
                    if(h_lf_flag_16=='Y'){
                    	$("#h_lf_flag_y_16").slideDown();
                    	showMedicalFee();
                    }*/

                    var h_lf_flag_15a = $scope.item29_h.h_lf_flag_15a;
                    if (h_lf_flag_15a == 'Y') {
                        $("#h_lf_flag_y_15a").slideDown();
                        showContent15a();
                    }

                    var h_lf_flag_16b = $scope.item29_h.h_lf_flag_16b;
                    if (h_lf_flag_16b == 'Y') {
                        $("#h_lf_flag_y_16b").slideDown();
                        showContent16b();
                    }

                }
                myFactory.loadingHide();
            }, function errorCallback(response) {
                alert('查询数据失败!');
                myFactory.loadingHide();
            });

            //备注信息弹窗控制
            $scope.remarkModelOkClose = function() {
                modal('close', 'remark_model', 'overwindow', 'remark_model_closeX');
            }
            $scope.remarkModelCancelClose = function() {
                modal('close', 'remark_model', 'overwindow', 'remark_model_closeX');
            }

            //检查结果弹窗控制
            $scope.checkResultModelOkClose = function() {
                modal('close', 'check_result_model', 'overwindow', 'check_result_model_closeX');
            }
            $scope.checkResultModelCancelClose = function() {
                modal('close', 'check_result_model', 'overwindow', 'check_result_model_closeX');
            }

            //吸烟告知弹窗控制
            $scope.smokeModelOkClose = function() {
                modal('close', 'smoke_model', 'overwindow', 'smoke_model_closeX');
            }
            $scope.smokeModelCancelClose = function() {
                modal('close', 'smoke_model', 'overwindow', 'smoke_model_closeX');
            }

            //喝酒告知弹窗控制
            $scope.drinkModelOkClose = function() {
                modal('close', 'drink_model', 'overwindow', 'drink_model_closeX');
            }
            $scope.drinkModelCancelClose = function() {
                modal('close', 'drink_model', 'overwindow', 'drink_model_closeX');
            }

            //移居境外告知弹窗控制
            $scope.moveModelOkClose = function() {
                modal('close', 'move_model', 'overwindow', 'move_model_closeX');
            }
            $scope.moveModelCancelClose = function() {
                modal('close', 'move_model', 'overwindow', 'move_model_closeX');
            }

            //5岁儿童体重弹窗控制
            $scope.weightModelOkClose = function() {
                modal('close', 'weight_model', 'overwindow', 'weight_model_closeX');
            }
            $scope.weightModelCancelClose = function() {
                modal('close', 'weight_model', 'overwindow', 'weight_model_closeX');
            }

            //怀孕弹窗控制
            $scope.pregnantModelOkClose = function() {
                modal('close', 'pregnant_model', 'overwindow', 'pregnant_model_closeX');
            }
            $scope.pregnantModelCancelClose = function() {
                modal('close', 'pregnant_model', 'overwindow', 'pregnant_model_closeX');
            }

            //喝酒种类选择
            /* $scope.isChecked = function(id){
				console.log("isChecked测试："+id);
		        return $scope.data.wineSelected.indexOf(id) >= 0 ;  
		    } ; */
            $scope.updateSelection = function($event, id) {
                var checkbox = $event.target;
                var checked = checkbox.checked;
                if (checked) {
                    $scope.data.wineSelected.removeArrByValue(id); //清除一下已存在数组的值然后再加入，后续就不必去重处理
                    $scope.data.wineSelected.push(id);
                    if (id == "4") { //other
                        $("#h3_other").slideDown();
                    }
                } else {
                    var idx = $scope.data.wineSelected.indexOf(id);
                    $scope.data.wineSelected.splice(idx, 1);
                    if (id == "4") { //other
                        $("#h3_other").slideUp();
                    }
                }
                $scope.data.wineSelected.sort();
                console.log("checkbox-wineSelected:" + $scope.data.wineSelected);

                /*$scope.data.wineSelected=id;
				console.log("wineSelected:"+id);
				if(id=="4"){//other
					$("#h3_other").slideDown();
				}else{//general
					$("#h3_other").slideUp();
				}*/
            };

            //返回上一页
            $scope.goBack = function() {
                myFactory.goBack();
                /*$.alert({title: '',text: '修改了信息还未保存，确认现在返回吗？',onOK: function () {
                	myFactory.goBack();
                }});*/
            }

            //关闭遮罩
            $scope.overwindowClose = function() {
                //$(".overwindow").show();
                $(".overwindow").hide();
                $(".overmodal").hide();
            }


            //公共变量定义
            var c_problemId = ""; //	题库编号
            var _role = "lf"; //	答题人角色（被保险人、被保险人）
            var _typeHealth = "h"; //	告知类型：健康告知
            var _typeAccount = "a"; //	告知类型：财务告知
            var _typeBusiness = "b"; //	告知类型：职业告知
            var _splitSign = "|"; //	分割符号，用于组装多个数据元素

            //	定义所有健康告知题库项编号
            //var answerKeyArray = new Array("3b","4a","4b","4c","4d","4e","4f","4g","4h","4i","4j","4k","5a","5b","5c","6","7","8","9","10","11","12","13","14","15","17a","17b","18a","18b");
            var answerKeyArray = new Array("2", "3", "4", "5", "6", "7", "8a", "8b", "8c", "8d", "8e", "8f", "8g", "8h", "8i", "8j", "8k", "9", "10a", "10b", "10c", "10d", "11", "12", "13", "14", "15a", "15b", "16a", "16b");
            //var answerKeyArray = new Array("2",'3a');

            /**********************  健康告知 start **************************/
            //	保存身高、体重信息(第一题)
            $scope.saveHealth01 = function(role, flag) {
                var ret = false;
                c_problemId = "1";
                _role = role;
                var _content = ""; //	填写内容
                //	获取字段名称值
                _content = $("#" + role + flag + "eight").val();

                if ("" == _content) {
                    myFactory.alert('', '身高或体重不能为空！', 'info');
                    return false;
                }

                if ('h' == flag) {
                    //$scope.numberVal('lfheight');
                    //var reg = /^\S{3}$/;
                    var reg = /[1-9]\d{1,3}/; //整数位只能输入3位数字；输入数字的首位不能为0
                    if (!reg.test($("#lfheight").val())) {
                        $.alert({ title: '', text: '请填写正确的身高！', onOK: function() {} });
                        $("#lfheight").val("");
                        return false;
                    }
                    //保存告知信息
                    saveNotifyData(_typeHealth, flag, _content, c_problemId);
                }

                if ('w' == flag) {
                    var reg = /(^[1-9]{1}[0-9]{0,2}$)|(^[1-9]{1}[0-9]{0,2}\.[0-9]{1}$)/;
                    if (!reg.test($("#lfweight").val())) {
                        $.alert({ title: '', text: '请填写正确的体重！', onOK: function() {} });
                        $("#lfweight").val("");
                        return false;
                    }
                    //保存告知信息
                    saveNotifyData(_typeHealth, flag, _content, c_problemId);
                }
                return true;
            }

            //	保存第16题信息--已取消
            /*$scope.saveMedicalFee = function(){
            	c_problemId = "16" ;
            	_role	   = "lf" ;
            	var content   = "" ;	//	来源数据
            	var medicalFee = document.getElementsByName("medicalFee");
            	for( var i=0 ; i< medicalFee.length ; i++ ){
            		if( medicalFee[i].checked == true ){
            			content += medicalFee[i].value + _splitSign;
            		}
            	}
            	//	保存告知信息
            	saveNotifyData(_typeHealth,"Y",content,c_problemId);
            }*/

            //体检检查结果 正常 异常
            $scope.healthCheck = function(problemId, result, role) {
                if ("Y" == result) {
                    $scope.data["h_" + role + "_button_y_" + problemId] = true;
                    $scope.data["h_" + role + "_button_n_" + problemId] = false;
                    $("#h_" + role + "_button_y_" + problemId).slideUp();
                    $("#h_remark_10b").val(""); //	清除原因记录
                } else {
                    $scope.data["h_" + role + "_button_y_" + problemId] = false;
                    $scope.data["h_" + role + "_button_n_" + problemId] = true;
                    $("#h_" + role + "_button_y_" + problemId).slideDown();
                }
            }

            //	打开健康告知对话框
            $scope.openHealthPop = function(problemId, role) {

                //	保存数据
                var _problemId = problemId;
                _role = role;

                var _content = $("#h_" + _role + "_" + _problemId).val(); //	原有填写内容

                if (isGeneralProblem(_problemId)) {
                    //	被保险人
                    /*if( _role=="lf" ){
                    	$("#th_general").html("被保险人告知事项");
                    }
                    //	被保险人
                    if( _role=="ow" ){
                    	$("#th_general").html("被保险人告知事项");
                    }*/

                    //	把原有值赋值到弹出框内容中
                    //$("#generalRemark" + _role +"_" + _problemId).val(_content);
                    //	显示弹出框
                    //$("#h_pop_general").popup("open");
                    var flagName = "h_" + _role + "_flag_y_" + _problemId;
                    var flagNameN = "h_" + _role + "_flag_n_" + _problemId;
                    $scope.data.radio_flag[flagName] = true;
                    $scope.data.radio_flag[flagNameN] = false;
                    //modal('open','h_pop_general','h_overwindow','h_pop_general_closeX');
                    $("#h_" + _role + "_flag_y_" + _problemId).slideDown();
                } else {
                    /*if( _role=="ow" ){
                    	$("#h_th_"+_problemId).html("被保险人告知事项");
                    }
                    if( _role=="lf" ){
                    	$("#h_th_"+_problemId).html("被保险人告知事项");
                    }*/

                    //	显示弹出框
                    //$("#h_pop_"+_problemId).popup("open");
                    var flagName = "h_" + _role + "_flag_y_" + _problemId;
                    var flagNameN = "h_" + _role + "_flag_n_" + _problemId;
                    $scope.data.radio_flag[flagName] = true;
                    $scope.data.radio_flag[flagNameN] = false;
                    //modal('open','h_pop_'+_problemId,'h_overwindow','h_pop_'+_problemId+'_closeX');
                    $("#h_" + _role + "_flag_y_" + _problemId).slideDown();
                    if ("10b" == _problemId) {
                        //h_pop_5b，h_remark_5b
                        //	保存页面所填写的内容
                        /*var _flag5b   = $("#h_" + _role + "_" + _problemId + "_flag" ).val();
                        var _remark5b = $("#h_" + _role + "_" + _problemId + "_remark" ).val();
                        if( "异常" == _flag5b ){
                        	document.getElementById("h_5b_yc").checked = "checked";;
                        } else if( "正常" == _flag5b ) {
                        	document.getElementById("h_5b_zc").checked = "checked";;
                        }
                        //	描述内容
                        $("#h_remark_5b" ).val(_remark5b);*/
                    }
                    if ("2" == _problemId) {
                        /*************   把答案赋值到弹出框中  **************/
                        //	获取答案值信息
                        /*var _year   = $("#h_" + _role + "_" + _problemId + "_1" ).val();	//	答案：年
                        var _number = $("#h_" + _role + "_" + _problemId + "_2" ).val();	//	答案：支
                        var _remark = $("#h_" + _role + "_" + _problemId + "_3" ).val();	//	答案：备注
                        //	赋值到弹出框
                        $("#h_7_year" ).val(_year);
                        $("#h_7_number" ).val(_number);
                        $("#h_7_remark" ).val(_remark);*/
                    }
                    if ("3" == _problemId) {
                        /*************   把答案赋值到弹出框中  *************/
                        //	获取答案值信息
                        /*var _year   = $("#h_" + _role + "_" + _problemId + "_year" ).val();	//	答案：年
                        var _wineType = $("#h_" + _role + "_" + _problemId + "_wineType" ).val();	//	答案：饮酒类型
                        var _other = $("#h_" + _role + "_" + _problemId + "_other" ).val();	//	答案：其它
                        var _week = $("#h_" + _role + "_" + _problemId + "_week" ).val();	//	答案：周
                        var _remark = $("#h_" + _role + "_" + _problemId + "_remark" ).val();	//	答案：备注

                        //	赋值到弹出框
                        $("#h_8_year" ).val(_year);
                        $("#h_8_other" ).val(_other);
                        $("#h_8_week" ).val(_week);
                        $("#h_8_remark" ).val(_remark);

                        var src = _wineType;*/

                        /*var wineTypes = document.getElementsByName("h_8_wineType");
                        /!*for( var i=0 ; i< wineTypes.length ; i++ ){
                        	if( src.indexOf( wineTypes[i].value ) > -1 ){
                        		wineTypes[i].checked = "checked" ;
                        	}else{
                        		wineTypes[i].checked = "" ;
                        	}
                        }*!/
                        var wineType=$scope.data.wineType;
                        for(var i = 0;i < wineType.length;i ++){
                        	/!*if(address.indexOf(wineType[i].id) == 0){
                        		//$scope.selectedDstrict=districtTemp[i].dutycode;
                        	}*!/
                        	if(src.indexOf( wineType[i].id ) > -1){
                        		wineTypes[i].checked = true ;
                        	}else{
                        		wineTypes[i].checked = false ;
                        	}
                        }*/
                        /*for( var i=0 ; i< wineTypes.length ; i++ ){
                        	console.log("indexof:"+src.indexOf( wineTypes[i].value));
                        	if( src.indexOf( wineTypes[i].value ) > -1 ){
                        		wineTypes[i].checked = true ;
                        	}else{
                        		wineTypes[i].checked = false ;
                        	}
                        }*/
                    }
                    if ("7" == _problemId) {
                        //	获取答案值信息
                        /*var _country= $("#h_" + _role + "_" + _problemId + "_country" ).val();		//	答案：国家
                        var _reason = $("#h_" + _role + "_" + _problemId + "_reason" ).val();		//	答案：原因
                        var _time 	= $("#h_" + _role + "_" + _problemId + "_time" ).val();		//	答案：时间
                        var _remark = $("#h_" + _role + "_" + _problemId + "_remark" ).val();		//	答案：备注
                        //	把答案显示在弹出框中
                        $("#h_pop_" + _problemId + "_country" ).val(_country);		//	答案：国家
                        $("#h_pop_" + _problemId + "_reason" ).val(_reason);	//	答案：原因
                        $("#h_pop_" + _problemId + "_time" ).val(_time);		//	答案：时间
                        $("#h_pop_" + _problemId + "_remark" ).val(_remark);		//	答案：备注*/
                    }

                    if ("15a" == _problemId) {
                        /*var _weight=$("#h_" + _role + "_" + _problemId + "_weight" ).val();	//	答案：出生体重
                        var _weeks=$("#h_" + _role + "_" + _problemId + "_weeks" ).val();		//	答案：怀孕周
                        var _dates=$("#h_" + _role + "_" + _problemId + "_dates" ).val();		//	答案：住院天数
                        var _remark=$("#h_" + _role + "_" + _problemId + "_remark" ).val();	//	答案：备注

                        $("#h_pop_" + _problemId + "_weight" ).val(_weight);	//	答案：出生体重
                        $("#h_pop_" + _problemId + "_weeks" ).val(_weeks);		//	答案：怀孕周
                        $("#h_pop_" + _problemId + "_dates" ).val(_dates);		//	答案：住院天数
                        $("#h_pop_" + _problemId + "_remark" ).val(_remark);	//	答案：备注*/
                    }

                    if ("16b" == _problemId) {
                        /*var _weeks=$("#h_" + _role + "_" + _problemId + "_weeks" ).val();		//	答案：怀孕周
                        var _remark=$("#h_" + _role + "_" + _problemId + "_remark" ).val();	//	答案：备注

                        $("#h_pop_" + _problemId + "_weeks" ).val(_weeks);		//	答案：怀孕周
                        $("#h_pop_" + _problemId + "_remark" ).val(_remark);	//	答案：备注*/
                    }

                }
            }

            //	确认、关闭健康告知弹出框
            $scope.confirmHealthPop = function(_problemId) {
                if (isGeneralProblem(_problemId)) {
                    var _content = ""; //	填写内容
                    //var generalDiv = document.getElementById("h_general_div");
                    //	把原有值赋值到弹出框内容中
                    _content = $("#generalRemark_" + _role + "_" + _problemId).val().trim();
                    if ("" == _content) {
                        //generalDiv.style.display='';		//	显示错误层
                        myFactory.alert('', '请填写' + _problemId + '备注栏信息！', 'info');
                        return false;
                    } else {
                        //generalDiv.style.display='none';	//	隐藏错误层
                        //	关闭弹出框
                        //$("#h_pop_general").popup("close");
                        //modal('close','h_pop_general','h_overwindow','h_pop_general_closeX');
                        $scope.setHealthAnswerYes(_problemId, _content);
                    }
                }

                if ("10b" == _problemId) {
                    var ck = $('input[name="result"]:checked').val();
                    var remark10b = $("#h_remark_10b").val().trim();
                    //var h_5b_div = document.getElementById("h_5b_div");	//	错误提示层
                    //h_5b_div.style.display='';	//	显示错误层
                    if (ck == null || ck == undefined) {
                        myFactory.alert('', '请选择检查结果！', 'info');
                        return false;
                    }
                    if (ck == "2" && !remark10b) {
                        myFactory.alert('', '请详细描述异常的检查结果！', 'info');
                        return false;
                    } else {
                        //h_5b_div.style.display='none';	//	隐藏错误层
                        //modal('close','h_pop_5b','h_overwindow','h_pop_5b_closeX');

                        /*var resDesc = "";
                        if( ck == "1" ){
                        	resDesc = "正常";
                        } else {
                        	resDesc = "异常";
                        }*/
                        //	保存页面所填写的内容
                        //$("#h_" + _role + "_" + _problemId + "_flag" ).val(resDesc);
                        //$("#h_" + _role + "_" + _problemId + "_remark" ).val(remark5b);

                        //var _content = ck + "," + remark10b ;
                        var _content = ck + _splitSign + remark10b;
                        //	显示区域内容
                        //hideHealthAnswer();
                        //	保存告知信息
                        saveNotifyData(_typeHealth, "Y", _content, _problemId);
                    }
                }
                if ("2" == _problemId) {
                    /*************   保存答案  **************/
                    //	获取弹出框填写值信息
                    var _year = $("#h_2_year").val(); //	答案：年
                    var _number = $("#h_2_number").val(); //	答案：支
                    //var _remark = $("#h_7_remark" ).val();	//	答案：备注
                    //var _7div = document.getElementById("h_7_div");	//	错误提示层

                    //	控制年、支不能为空
                    if ("" == _year || "" == _number) {
                        //_7div.style.display='';	//	显示错误层
                        //$("#h_errorMsg_7").html("请填写完整吸烟年份及每天多少支！");
                        myFactory.alert('', '请填写完整吸烟年份及每天多少支！', 'info');
                        return false;
                    } //else {
                    //_7div.style.display='none';	//	隐藏错误层
                    //$("#h_pop_7").popup("close");
                    //modal('close','h_pop_7','h_overwindow','h_pop_7_closeX');
                    //}
                    //	保存答案信息
                    //$("#h_" + _role + "_" + _problemId + "_1" ).val(_year);
                    //$("#h_" + _role + "_" + _problemId + "_2" ).val(_number);
                    //$("#h_" + _role + "_" + _problemId + "_3" ).val(_remark);

                    //var reg = /^\+?[1-9]\d*$/;
                    var reg = /(^[1-9]{1}[0-9]{0,2}$)/;
                    if (!reg.test(_year)) {
                        $.alert({ title: '', text: '请输入合法年份！', onOK: function() {} });
                        return false;
                    }

                    //var _content = _year + _splitSign + _number + _splitSign + _remark ;
                    var _content = _year + _splitSign + _number + _splitSign;
                    //	显示区域内容
                    //hideHealthAnswer();
                    //	保存告知信息
                    saveNotifyData(_typeHealth, "Y", _content, _problemId);
                }

                if ("3" == _problemId) {
                    /*************   保存答案  **************/
                    //	获取弹出框填写值信息
                    var _year = $("#h_3_year").val().trim(); //	答案：年
                    var _week = $("#h_3_week").val().trim(); //	答案：(周/两)

                    var _wineType = ""; //	答案：饮酒类型
                    var _other = $("#h_3_other").val().trim(); //	答案：其它信息
                    //var _remark = $("#h_8_remark" ).val().trim();	//	答案：备注
                    //var _err8div = document.getElementById("h_8_err_div");	//	错误提示层

                    var wines = document.getElementsByName("h_3_wineType");
                    var _wineTypeDesc = ""; //	答案：饮酒类型(中文描述)

                    /*for( var i=0 ; i< wines.length ; i++ ){
                    	if( wines[i].checked == true ){
                    		_wineType += wines[i].value + ",";
                    	}
                    }*/
                    /*var wineType=$scope.data.wineType;
                    for( var i=0 ; i< wines.length ; i++ ){
                    	if( wines[i].checked == true ){
                    		_wineType += wineType[i].id + ",";
                    		//$scope.data.wineSelected.push(wineType[i].id) ;
                    		//_wineType=$scope.data.wineSelected;//[1,2,3]==>1,2,3
                    	}
                    }*/

                    _wineType = $scope.data.wineSelected;
                    //	获取名称
                    /*_wineTypeDesc = getWineTypeDesc(_wineType);
                    if(_wineType=="4"){
                    	if(_wineTypeDesc==""){
                    		myFactory.alert('','请输入其他酒类信息','info');
                    		return false;
                    	}
                    }else{
                    	$("#h_3_other").val("");
                    }*/

                    /*$scope.updateSelection = function($event,id){
                    	var checkbox = $event.target ;
                    	var checked = checkbox.checked ;
                    	if(checked){
                    		$scope.data.wineSelected.push(id) ;
                    	}else{
                    		var idx = $scope.data.wineSelected.indexOf(id) ;
                    		$scope.data.wineSelected.splice(idx,1) ;
                    	}
                    	console.log($scope.data.wineSelected);
                    };
                    var wineType=$scope.data.wineType;
                    for(var i = 0;i < wineType.length;i ++){
                    	/!*if(address.indexOf(wineType[i].id) == 0){
                    	 //$scope.selectedDstrict=districtTemp[i].dutycode;
                    	 }*!/
                    	if(src.indexOf( wineType[i].id ) > -1){
                    		wineTypes[i].checked = true ;
                    	}else{
                    		wineTypes[i].checked = false ;
                    	}
                    }*/

                    //	控制年、饮酒类型不能为空
                    if ("" == _year || "" == _wineType || "" == _week) {
                        //_err8div.style.display='';		//	显示错误层
                        //$("#msg_8").html("请填写完整饮酒习惯信息！");
                        myFactory.alert('', '请填写完整饮酒习惯信息！', 'info');
                        return false;
                    } //else {
                    //_err8div.style.display='none';	//	隐藏错误层
                    //$("#h_pop_8").popup("close");
                    //modal('close','h_pop_8','h_overwindow','h_pop_8_closeX');
                    //}

                    var reg = /(^[1-9]{1}[0-9]{0,2}$)/;
                    if (!reg.test(_year)) {
                        $.alert({ title: '', text: '请输入合法年份！', onOK: function() {} });
                        return false;
                    }

                    //	保存答案信息
                    /*$("#h_" + _role + "_" + _problemId + "_year" ).val(_year);
                    $("#h_" + _role + "_" + _problemId + "_wineType" ).val(_wineType);
                    $("#h_" + _role + "_" + _problemId + "_wineTypeDesc" ).val(_wineTypeDesc);
                    $("#h_" + _role + "_" + _problemId + "_other" ).val(_other);
                    $("#h_" + _role + "_" + _problemId + "_week" ).val(_week);
                    $("#h_" + _role + "_" + _problemId + "_remark" ).val(_remark);*/

                    var _content = "";
                    if ($scope.data.wineSelected.indexOf(4) > -1) {
                        //if(_wineType=="4"){
                        if (_other == "") {
                            myFactory.alert('', '请输入其他酒类信息', 'info');
                            return false;
                        }
                        //_content = _year + _splitSign + _wineType + _splitSign + _other +_splitSign + _week +_splitSign;
                        _content = _year + _splitSign + _week + _splitSign + _wineType + _splitSign + _other + _splitSign;
                    } else {
                        $("#h_3_other").val("");
                        _content = _year + _splitSign + _week + _splitSign + _wineType + _splitSign;
                    }

                    //	显示区域内容
                    //hideHealthAnswer();
                    //	保存告知信息
                    saveNotifyData(_typeHealth, "Y", _content, _problemId);
                }
                if ("7" == _problemId) {
                    var _country = $("#h_pop_" + _problemId + "_country").val().trim(); //	答案：国家
                    var _reason = $("#h_pop_" + _problemId + "_reason").val().trim(); //	答案：原因
                    var _time = $("#h_pop_" + _problemId + "_time").val().trim(); //	答案：时间
                    //var _remark = $("#h_pop_" + _problemId + "_remark" ).val().trim();		//	答案：备注

                    $("#h_" + _role + "_" + _problemId + "_country").val(_country); //	答案：国家
                    $("#h_" + _role + "_" + _problemId + "_reason").val(_reason); //	答案：原因
                    $("#h_" + _role + "_" + _problemId + "_time").val(_time); //	答案：时间
                    //$("#h_" + _role + "_" + _problemId + "_remark" ).val(_remark);		//	答案：备注

                    //var _err15div = document.getElementById("h_15_err_div");	//	错误提示层

                    //	控制不能为空值
                    if ("" == _country || "" == _reason || "" == _time) {
                        //_err15div.style.display='';		//	显示错误层
                        //$("#msg_15").html("请填写完整信息！");
                        myFactory.alert('', '请填写完整的境外居住信息！', 'info');
                        return false;
                    } //else {
                    //_err15div.style.display='none';	//	隐藏错误层
                    //$("#h_pop_15").popup("close");
                    //modal('close','h_pop_15','h_overwindow','h_pop_15_closeX');
                    //}

                    var _content = _country + _splitSign + _reason + _splitSign + _time + _splitSign;

                    //	显示区域内容
                    //hideHealthAnswer();
                    //	保存告知信息
                    saveNotifyData(_typeHealth, "Y", _content, _problemId);
                }

                if ("12" == _problemId) {
                    /*************   保存答案  **************/
                    //	获取弹出框填写值信息
                    var _remark12 = $("#generalRemark_lf_12").val().trim(); //	答案：年
                    var _money12 = $("#h_pop_12_money").val(); //	答案：支

                    if ("" == _remark12) {
                        myFactory.alert('', '请说明保险公司名称、险种名称、保险金额和生效/申请时间！', 'info');
                        return false;
                    }

                    var _content = "";
                    if (lfAge < 18) {
                        if ("" == _money12) {
                            myFactory.alert('', '请填写身故保险金额总和！', 'info');
                            return false;
                        }

                        //var reg=/^[0-9]\d*(\.\d+)?$/ ;//    /(^[1-9]{1}[0-9]*$)|(^[0-9]*\.[0-9]{2}$)/
                        //var reg=/(^[1-9]{1}[0-9]*$)|(^[0-9]*\.[0-9]{2}$)/;  
                        /*var reg = /(^[0]{1}$)|(^[1-9]{1}[0-9]{0,9}$)|(^[0-9]{1}\.[0-9]{1}$)|(^[1-9]{1}[0-9]{0,9}\.[0-9]{1}$)/;
                        if(!reg.test(_money12)){
                        	$.alert({title: '',text: '保险金额总和只能为数字且小数点后最多保留一位！',onOK: function () {}});
                        	return false;
                        }*/
                        var reg = /^[1-9]{1}\d*(\.\d{1,2})?$/;
                        if (!reg.test(_money12)) {
                            myFactory.alert("", "请输入合法保险金额！", "info");
                            return false;
                        }
                        _content = _remark12 + _splitSign + _money12 + _splitSign;
                    } else {
                        _content = _remark12 + _splitSign;
                    }

                    //	保存告知信息
                    saveNotifyData(_typeHealth, "Y", _content, _problemId);
                }


                if ("15a" == _problemId) {
                    var _weight = $("#h_pop_" + _problemId + "_weight").val().trim(); //	答案：出生体重
                    var _dates = $("#h_pop_" + _problemId + "_dates").val().trim(); //	答案：住院天数
                    var _weeks = $("#h_pop_" + _problemId + "_weeks").val().trim(); //	答案：怀孕周
                    var _remark = $("#h_pop_" + _problemId + "_remark").val().trim(); //	答案：备注

                    /*$("#h_" + _role + "_" + _problemId + "_weight" ).val(_weight);		//	答案：出生体重
                    $("#h_" + _role + "_" + _problemId + "_weeks" ).val(_weeks);		//	答案：怀孕周
                    $("#h_" + _role + "_" + _problemId + "_dates" ).val(_dates);		//	答案：住院天数
                    $("#h_" + _role + "_" + _problemId + "_remark" ).val(_remark);		//	答案：备注*/

                    //var _err17div = document.getElementById("h_17a_err_div");	//	错误提示层

                    //	控制不能为空值
                    if ("" == _weight || "" == _weeks || "" == _dates) {
                        //_err17div.style.display='';		//	显示错误层
                        //$("#msg_17a").html("请填写完整信息！");
                        myFactory.alert('', '请填写完整的儿童出生信息！', 'info');
                        return false;
                    } //else {
                    //_err17div.style.display='none';	//	隐藏错误层
                    //modal('close','h_pop_17a','h_overwindow','h_pop_17a_closeX');
                    //}
                    if ("" == _remark) {
                        myFactory.alert('', '请填写出院诊断！', 'info');
                        return false;
                    }

                    //var reg = /^\+?[1-9]\d*$/;
                    var reg = /(^[0]{1}$)|(^[1-9]{1}[0-9]{0,8}$)/;
                    if (!reg.test(_dates)) {
                        $.alert({ title: '', text: '请输入合法住院天数！', onOK: function() {} });
                        return false;
                    }

                    //var regw=/^[1-9]\d*(\.\d+)?$/;
                    //var regw=/(^[1-3]{1}[0-9]{0,2}$)|(^[1-3]{1}[0-9]{0,2}\.[0-9]{1}$)/;
                    var regw = /(^[1-9]{1}[0-9]{0,2}$)|(^[1-9]{1}[0-9]{0,2}\.[0-9]{1}$)/;
                    if (!regw.test(_weight)) {
                        $.alert({ title: '', text: '请填写正确的体重！', onOK: function() {} });
                        return false;
                    }

                    var _content = _weight + _splitSign + _weeks + _splitSign + _dates + _splitSign + _remark;

                    //	显示区域内容
                    //hideHealthAnswer();
                    //	保存告知信息
                    saveNotifyData(_typeHealth, "Y", _content, _problemId);
                }

                if ("16b" == _problemId) {
                    var _weeks = $("#h_pop_" + _problemId + "_weeks").val().trim(); //	答案：怀孕周
                    var _remark = $("#h_pop_" + _problemId + "_remark").val().trim(); //	答案：备注

                    //$("#h_" + _role + "_" + _problemId + "_weeks" ).val(_weeks);		//	答案：怀孕周
                    //$("#h_" + _role + "_" + _problemId + "_remark" ).val(_remark);		//	答案：备注

                    //var _err18div = document.getElementById("h_18b_err_div");	//	错误提示层

                    //	控制不能为空值
                    if ("" == _weeks || "" == _remark) {
                        //_err18div.style.display='';		//	显示错误层
                        //$("#msg_18b").html("请填写完整信息！");
                        myFactory.alert('', '请填写怀孕信息！', 'info');
                        return false;
                    } //else {
                    //_err18div.style.display='none';	//	隐藏错误层
                    //$("#h_pop_18b").popup("close");
                    //modal('close','h_pop_18b','h_overwindow','h_pop_18b_closeX');
                    //}

                    /*var reg = /^\+?[1-9]\d*$/;
                    if(!reg.test(_weeks)){
                    	$.alert({title: '',text: '请输入大于0的正整数！',onOK: function () {}});
                    	return false;
                    }*/

                    var _content = _weeks + _splitSign + _remark;

                    //	显示区域内容
                    //hideHealthAnswer();
                    //	保存告知信息
                    saveNotifyData(_typeHealth, "Y", _content, _problemId);
                }
                return true;
            }

            //	设置健康告知回答为<是>
            $scope.setHealthAnswerYes = function(problemId, content) {
                //	保存页面所填写的内容
                //$("#h_" + _role + "_" + _problemId ).val(content);
                //	显示区域内容
                //hideHealthAnswer();
                //	保存告知信息
                saveNotifyData(_typeHealth, "Y", content, problemId);
            }

            //	设置健康告知回答为<否>
            $scope.setHealthAnswerNo = function(problemId, role) {
                //删除选择"否"的problemId
                /*problemIdArr.removeArrByValue(problemId);
                console.log("problemIdArr:"+problemIdArr);
                problemIdArr.sort();
                console.log("sort problemIdArr:"+problemIdArr);*/

                //	保存数据
                var _problemId = problemId;
                _role = role;

                //var flagName="h_" + _role + "_flag_" + _problemId;
                //$scope.data.radio_flag[flagName] = false;
                var flagName = "h_" + _role + "_flag_y_" + _problemId;
                var flagNameN = "h_" + _role + "_flag_n_" + _problemId;
                $scope.data.radio_flag[flagName] = false;
                $scope.data.radio_flag[flagNameN] = true;
                $("#h_" + _role + "_flag_y_" + _problemId).slideUp();

                //特殊选项清除数据
                if ("10b" == problemId) {
                    $scope.data["h_" + role + "_button_y_" + problemId] = false;
                    $scope.data["h_" + role + "_button_n_" + problemId] = false;
                    $("#h_" + role + "_button_y_" + problemId).slideUp();
                    $("#h_remark_10b").val(""); //	清除原因记录
                }

                //	隐藏区域内容
                //hideHealthAnswer(_role);
                //	保存告知信息
                saveNotifyData(_typeHealth, "N", "", _problemId);
            }

            //	隐藏问题内容
            function hideHealthAnswer() {
                for (var i = 0; i < answerKeyArray.length; i++) {
                    var _currProblemId = answerKeyArray[i]; //	当前题库编号
                    var lfId = "h_tb_lf_" + _currProblemId;
                    //var owId = "h_tb_ow_" + _currProblemId ;

                    //var lf_flag = $("input:radio[name=B_"+_currProblemId.toUpperCase()+"]:checked").val();	//	当前编号对应的被保险人题库值
                    var lf_flagName = "h_lf_flag_y_" + _currProblemId;
                    var lf_flag = $scope.data.radio_flag[lf_flagName];

                    //	没有选择被保险人的"是、否"选项时隐藏当前变更项所属区域块内容
                    if (lf_flag) {
                        //document.getElementById(lfId).style.display="";
                        //$scope.data["a_lf_" + _currProblemId+'_ShowFlag']=true;
                        $scope.data.radio_flag[lfId] = true;
                    } else {
                        //document.getElementById(lfId).style.display="none";
                        $scope.data.radio_flag[lfId] = false;
                    }

                    /*var ow_flag = $("input:radio[name=T_"+_currProblemId.toUpperCase()+"]:checked").val();	//	当前编号对应的被保险人题库值
                    //	没有选择投保险人的"是、否"选项时隐藏当前变更项所属区域块内容
                    if( "Y" == ow_flag){
                    	document.getElementById(owId).style.display="";
                    } else {
                    	document.getElementById(owId).style.display="none";
                    }*/

                }
            }


            //保存按钮：保存数据[主要为选择“是”弹出的输入框数据保存方法]
            $scope.saveData = function() {
                //console.log("save problemIdArr:"+problemIdArr);
                var returnFlag; //保存状态
                var returnFlagAllNo = 0; //returnFlagAllNo
                //遍历数组，循环保存
                var _problemId = "";
                /*for(var i=0;i<problemIdArr.length;i++) {
                	_problemId=problemIdArr[i];
                	console.log("problemId saving begin:"+_problemId);
                	returnFlag = $scope.confirmHealthPop(_problemId);
                	console.log("problemId saving end:"+_problemId);
                	if(!returnFlag){
                		console.log(_problemId+"save error");
                		break;
                	}
                }*/

                var returnFlagNum = 0;
                var flagName = "";
                var flagNameTemp = "";

                //单独保存1
                returnFlag = $scope.saveHealth01('lf', 'h');
                if (!returnFlag) {
                    return false;
                }
                returnFlag = $scope.saveHealth01('lf', 'w');
                if (!returnFlag) {
                    return false;
                }

                //var problemIdSaveArray = new Array("3b","4a","4b","4c","4d","4e","4f","4g","4h","4i","4j","4k","5a","5b","5c","6","7","8","9","10","11","12","13","14","15","17a","17b","18a","18b");
                var problemIdSaveArray = new Array("2", "3", "4", "5", "6", "7", "8a", "8b", "8c", "8d", "8e", "8f", "8g", "8h", "8i", "8j", "8k", "9", "10a", "10b", "10c", "10d", "11", "12", "13", "14", "15a", "15b", "16a", "16b");
                var lenSave = problemIdSaveArray.length;
                for (var i = 0; i < lenSave; i++) {
                    _problemId = problemIdSaveArray[i];
                    flagName = "h_" + _role + "_flag_y_" + _problemId;
                    flagNameTemp = $scope.data.radio_flag[flagName];
                    if (flagNameTemp) { //选择是的情况才保存判断
                        console.log("problemId saving begin:" + _problemId);
                        returnFlag = $scope.confirmHealthPop(_problemId);
                        console.log("problemId saving end:" + _problemId);
                        if (!returnFlag) {
                            console.log(_problemId + "save error");
                            returnFlagNum = -1;
                            break;
                        }
                    } else {
                        returnFlagAllNo++;
                    }
                }

                if (returnFlagNum == -1) {
                    return false;
                }

                //if(returnFlag || problemIdArr.length==0){
                if (returnFlag || returnFlagAllNo > 0) { //选择部分是或者全部否
                    //成功保存
                    //myFactory.alert('','保存成功！','info');
                    $.alert({
                        title: '',
                        text: '保存成功',
                        onOK: function() {
                            //点击确定才返回上一页
                            myFactory.goBack();
                        }
                    });
                } else {
                    myFactory.alert('', '保存失败！', 'info');
                }
            }

            //	展示第5b题
            function showContent10b() {
                /*****  被保险人 ****/
                var hisCnt = $scope.item29_h.h_lf_10b; //	原有填写金额及原因内容
                var flag10b = hisCnt.substring(0, 1);
                var remark10b = hisCnt.substring(2, hisCnt.length);
                if ("1" == flag10b) {
                    document.getElementById("h_10b_zc").checked = "checked";
                    $scope.data["h_lf_button_y_10b"] = true;
                    $scope.data["h_lf_button_n_10b"] = false;
                    $("#h_lf_button_y_10b").slideUp();
                    $("#h_remark_10b").val(""); //	原因
                } else {
                    //flag10b = "异常";
                    document.getElementById("h_10b_yc").checked = "checked";
                    $scope.data["h_lf_button_y_10b"] = false;
                    $scope.data["h_lf_button_n_10b"] = true;
                    $("#h_lf_button_y_10b").slideDown();

                    //$("#h_lf_5b_flag").val(flag5b);		//	检测结果
                    //$("#h_lf_5b_remark").val(remark5b);	//	原因
                    $("#h_remark_10b").val(remark10b); //	原因
                }

                /****** 被保险人 *****/
                /*hisCnt = '${h_ow_5b }';			//	原有填写金额及原因内容
                flag5b = hisCnt.substring(0,1);
                remark5b=hisCnt.substring(2,hisCnt.length);
                if( "1" == flag5b ){
                	flag5b = "正常";
                }else {
                	flag5b = "异常";
                }
                $("#h_ow_5b_flag").val(flag5b);		//	检测结果
                $("#h_ow_5b_remark").val(remark5b);	//	原因*/
            }
            //	展示第2题答案
            function showContent2() {
                /*****  被保险人 ****/
                var hisCnt = $scope.item29_h.h_lf_2; //	原有填写金额及原因内容
                var cnts = hisCnt.split(_splitSign);

                //	保存答案信息
                /*$("#h_lf_7_1" ).val(cnts[0]);
                $("#h_lf_7_2" ).val(cnts[1]);
                $("#h_lf_7_3" ).val(cnts[2]);*/
                $("#h_2_year").val(cnts[0]);
                $("#h_2_number").val(cnts[1]);

                /*****  被保险人 ****/
                /*var hisCnt = '${h_ow_7 }';		//	原有填写金额及原因内容
                var cnts = hisCnt.split(_splitSign);

                //	保存答案信息
                $("#h_ow_7_1" ).val(cnts[0]);
                $("#h_ow_7_2" ).val(cnts[1]);
                $("#h_ow_7_3" ).val(cnts[2]);*/
            }

            //	展示第3题答案
            function showContent3() {

                var _wineTypeDesc = ""; //	答案：饮酒类型(中文描述)

                /*****  被保险人 ****/
                //var hisCnt = '${h_lf_2 }';		//	原有填写金额及原因内容
                var hisCnt = $scope.item29_h.h_lf_3;
                if ("" == hisCnt) {
                    hisCnt = "" + _splitSign + "" + _splitSign + "" + _splitSign + "" + _splitSign;
                }
                var cnts = hisCnt.split(_splitSign);

                var _wineType = cnts[2];
                /*if(_wineType=="4"){
                	$("#h3_other").slideDown();
                }else{//general
                	$("#h3_other").slideUp();
                }*/
                //$scope.data.wineSelected=_wineType;

                /*var wineTypes = document.getElementsByName("h_3_wineType");
                var wineType=$scope.data.wineType;
                for(var i = 0;i < wineType.length;i ++){
                	if(_wineType.indexOf( wineType[i].id ) > -1){
                		wineTypes[i].checked = true ;
                	}else{
                		wineTypes[i].checked = false ;
                	}
                }*/
                var wineTypes = document.getElementsByName("h_3_wineType");
                var wineType = $scope.data.wineType;
                for (var i = 0; i < wineType.length; i++) {
                    if (_wineType.indexOf(wineType[i].id) > -1) {
                        wineTypes[i].checked = true;
                        $scope.data.wineSelected.push(wineType[i].id);
                    } else {
                        wineTypes[i].checked = false;
                    }
                }

                //	获取名称
                //_wineTypeDesc = getWineTypeDesc(cnts[2]);

                //	保存答案信息
                /*$("#h_lf_8_year").val(cnts[0]);
                $("#h_lf_8_wineType").val(cnts[1]);
                $("#h_lf_8_wineTypeDesc").val(_wineTypeDesc);
                $("#h_lf_8_other").val(cnts[2]);
                $("#h_lf_8_week").val(cnts[3]);
                $("#h_lf_8_remark").val(cnts[4]);*/
                $("#h_3_year").val(cnts[0]);
                //$("#h_3_wineType").val(cnts[2]);
                //$("#h_3_wineTypeDesc").val(_wineTypeDesc);

                if ($scope.data.wineSelected.indexOf(4) > -1) {
                    $("#h3_other").slideDown();
                    $("#h_3_other").val(cnts[3]);
                    $("#h_3_week").val(cnts[1]);
                } else { //general
                    $("#h3_other").slideUp();
                    $("#h_3_week").val(cnts[1]);
                }

                /*****  被保险人 ****/
                /*var hisCnt = '${h_ow_8 }';		//	原有填写金额及原因内容
                if(""==hisCnt){
                	hisCnt = ""+_splitSign+""+_splitSign+""+_splitSign+""+_splitSign;
                }
                var cnts = hisCnt.split(_splitSign);

                var _wineTypeDesc = "";	//	答案：饮酒类型(中文描述)
                //	获取名称
                _wineTypeDesc = getWineTypeDesc(cnts[1]);

                //	保存答案信息
                $("#h_ow_8_year").val(cnts[0]);
                $("#h_ow_8_wineType").val(cnts[1]);
                $("#h_ow_8_wineTypeDesc").val(_wineTypeDesc);
                $("#h_ow_8_other").val(cnts[2]);
                $("#h_ow_8_week").val(cnts[3]);
                $("#h_ow_8_remark").val(cnts[4]);*/
            }

            //	展示第7题答案
            function showContent7() {
                //var hisCnt = '${h_lf_15 }';		//	原有填写金额及原因内容
                var hisCnt = $scope.item29_h.h_lf_7;
                var curRole = "pop";
                var cnts = hisCnt.split(_splitSign);

                //$("#h_" + curRole + "_15_country" ).val(cnts[0]);	//	答案：国家
                //$("#h_" + curRole + "_15_reason" ).val(cnts[1]);		//	答案：原因
                //$("#h_" + curRole + "_15_time" ).val(cnts[2]);		//	答案：时间
                //$("#h_" + curRole + "_15_remark" ).val(cnts[3]);		//	答案：备注
                $("#h_" + curRole + "_7_country").val(cnts[0]); //	答案：国家
                $("#h_" + curRole + "_7_reason").val(cnts[1]); //	答案：原因
                $("#h_" + curRole + "_7_time").val(cnts[2]); //	答案：时间

                /*var hisCnt = '${h_ow_15 }';		//	原有填写金额及原因内容
                var curRole = "ow";
                var cnts = hisCnt.split(_splitSign);
                $("#h_" + curRole + "_15_country" ).val(cnts[0]);	//	答案：国家
                $("#h_" + curRole + "_15_reason" ).val(cnts[1]);		//	答案：原因
                $("#h_" + curRole + "_15_time" ).val(cnts[2]);		//	答案：时间
                $("#h_" + curRole + "_15_remark" ).val(cnts[3]);		//	答案：备注*/
            }

            //	显示第16题信息--已取消
            /*function showMedicalFee(){
            	//var src = "${h_lf_16}";
            	var src = $scope.item23_h.h_lf_16;
            	var medicalFee = document.getElementsByName("medicalFee");
            	for( var i=0 ; i< medicalFee.length ; i++ ){
            		if( src.indexOf( medicalFee[i].value ) > -1 ){
            			medicalFee[i].checked = true ;
            		}else{
            			medicalFee[i].checked = false ;
            		}
            	}
            }*/

            //	展示第12题答案
            function showContent12() {
                /*****  被保险人 ****/
                var hisCnt = $scope.item29_h.h_lf_12;
                var cnts = hisCnt.split(_splitSign);

                //	保存答案信息
                $("#generalRemark_lf_12").val(cnts[0]);
                $("#h_pop_12_money").val(cnts[1]);

            }

            //	展示第15a题答案
            function showContent15a() {
                //var hisCnt = '${h_lf_14a }';		//	原有填写金额及原因内容
                var hisCnt = $scope.item29_h.h_lf_15a;
                //var curRole = "lf";
                var curCon = "pop";
                var cnts = hisCnt.split(_splitSign);

                $("#h_" + curCon + "_15a_weight").val(cnts[0]); //	答案：出生体重
                $("#h_" + curCon + "_15a_weeks").val(cnts[1]); //	答案：怀孕周
                $("#h_" + curCon + "_15a_dates").val(cnts[2]); //	答案：住院天数
                $("#h_" + curCon + "_15a_remark").val(cnts[3]); //	答案：备注

                /*var hisCnt = '${h_ow_17a }';		//	原有填写金额及原因内容
                var curRole = "ow";
                var cnts = hisCnt.split(_splitSign);

                $("#h_" + curRole + "_17a_weight" ).val(cnts[0]);		//	答案：出生体重
                $("#h_" + curRole + "_17a_weeks" ).val(cnts[1]);		//	答案：怀孕周
                $("#h_" + curRole + "_17a_dates" ).val(cnts[2]);		//	答案：住院天数
                $("#h_" + curRole + "_17a_remark" ).val(cnts[3]);		//	答案：备注*/
            }

            //	展示第16b题答案
            function showContent16b() {
                //var hisCnt = '${h_lf_15b }';		//	原有填写金额及原因内容
                var hisCnt = $scope.item29_h.h_lf_16b;
                //var curRole = "lf";
                var curCon = "pop";
                var cnts = hisCnt.split(_splitSign);

                $("#h_" + curCon + "_16b_weeks").val(cnts[0]); //	答案：怀孕周
                $("#h_" + curCon + "_16b_remark").val(cnts[1]); //	答案：备注

                /*var hisCnt = '${h_ow_18b }';		//	原有填写金额及原因内容
                var curRole = "ow";
                var cnts = hisCnt.split(_splitSign);

                $("#h_" + curRole + "_18b_weeks" ).val(cnts[0]);		//	答案：怀孕周
                $("#h_" + curRole + "_18b_remark" ).val(cnts[1]);		//	答案：备注*/
            }

            //	获取饮酒类型名称
            function getWineTypeDesc(wines) {
                if ("" == wines) {
                    return "";
                }
                //var types = wines.split(",");

                var _wineTypeDesc = ""; //	答案：饮酒类型(中文描述)

                /*for( var i=0 ; i< types.length ; i++ ){
                	if( "1" == types[i] ){
                		_wineTypeDesc += "啤酒,"
                	}
                	if( "2" == types[i] ){
                		_wineTypeDesc += "白酒,"
                	}
                	if( "3" == types[i] ){
                		_wineTypeDesc += "红酒,"
                	}
                }

                if( _wineTypeDesc.length > 1 ){
                	_wineTypeDesc = _wineTypeDesc.substring(0,_wineTypeDesc.length-1);
                }*/

                if ("1" == wines) {
                    _wineTypeDesc = "啤酒";
                }
                if ("2" == wines) {
                    _wineTypeDesc = "白酒";
                }
                if ("3" == wines) {
                    _wineTypeDesc = "红酒";
                }
                if ("4" == wines) {
                    var _other = $("#h_3_other").val().trim(); //	答案：其它信息
                    _wineTypeDesc = _other;
                }

                return _wineTypeDesc;
            }

            //	是否为一般问题件
            function isGeneralProblem(_problemId) {
                /*if( _problemId == "2"  ||
                	_problemId == "3a" || _problemId == "3b" ||
                	_problemId == "4a" || _problemId == "4b" || _problemId == "4c" || _problemId == "4d" || _problemId == "4e" ||
                	_problemId == "4f" || _problemId == "4g" || _problemId == "4h" || _problemId == "4i" || _problemId == "4j" || _problemId == "4k" ||
                	_problemId == "5a" || _problemId == "5c" ||
                	_problemId == "6"  ||
                	_problemId == "9"  || _problemId == "10" || _problemId == "11" ||
                	_problemId == "12" || _problemId == "13" || _problemId == "14" ||
                	_problemId == "17b"|| _problemId == "18a"
                ){
                	return true;
                } else {
                	return false;
                }*/
                if (
                    /*_problemId == "3b" ||
					_problemId == "4a" || _problemId == "4b" || _problemId == "4c" || _problemId == "4d" || _problemId == "4e" ||
					_problemId == "4f" || _problemId == "4g" || _problemId == "4h" || _problemId == "4i" || _problemId == "4j" || _problemId == "4k" ||
					_problemId == "5a" || _problemId == "5c" ||
					_problemId == "6"  ||
					_problemId == "9"  || _problemId == "10" || _problemId == "11" ||
					_problemId == "12" || _problemId == "13" || _problemId == "14" ||
					_problemId == "17b"|| _problemId == "18a"*/
                    /*_problemId == "8" ||
                    _problemId == "7a" || _problemId == "7b" || _problemId == "7c" || _problemId == "7d" || _problemId == "7e" ||
                    _problemId == "7f" || _problemId == "7g" || _problemId == "7h" || _problemId == "7i" || _problemId == "7j" || _problemId == "7k" ||
                    _problemId == "9a" || _problemId == "9c" ||  _problemId == "9d" ||
                    _problemId == "4"  ||
                    _problemId == "3"  || _problemId == "10" ||
                    _problemId == "12" || _problemId == "13" || _problemId == "5" ||
                    _problemId == "14b"|| _problemId == "15a"*/
                    _problemId == "9" ||
                    _problemId == "8a" || _problemId == "8b" || _problemId == "8c" || _problemId == "8d" || _problemId == "8e" ||
                    _problemId == "8f" || _problemId == "8g" || _problemId == "8h" || _problemId == "8i" || _problemId == "8j" || _problemId == "8k" ||
                    _problemId == "10a" || _problemId == "10c" || _problemId == "10d" ||
                    _problemId == "5" ||
                    _problemId == "4" || _problemId == "11" ||
                    _problemId == "13" || _problemId == "14" || _problemId == "6" ||
                    _problemId == "15b" || _problemId == "16a"
                ) {
                    return true;
                } else {
                    return false;
                }
            }
            /**********************  健康告知 end **************************/


            /**
             * 保存数据到后台
             * type - 告知类型 (H-健康告知,A-财务告知,B-职业告知)
             * flag - 答题状态位（是、否）
             * content - 答题内容
             **/
            function saveNotifyData(_type, _flag, _content, _problemId) {
                var ret = false;
                var returnFlag = "";
                //	对字符串编码
                var deContent = encodeURI(_content);
                var timestamp = myFactory.getTimetamp();
                var sfis = "type-problemId-role-flag-token-timestamp";
                var signStr = "type=" + _type + "&problemId=" + _problemId + "&role=" + _role + "&flag=" + _flag + "&token=" + token + "&timestamp=" + timestamp; //encodeURI(name)
                var sign = myFactory.hex(signStr);
                var param = { 'type': _type, 'problemId': _problemId, 'role': _role, 'flag': _flag, 'content': deContent, 'sign': sign, 'sfis': sfis, 'token': token, 'timestamp': timestamp };
                $http({
                    method: 'GET',
                    url: app.domain + 'common/saveNotify29.action',
                    params: param
                }).then(function successCallback(response) {
                    if (response.data.success) {
                        returnFlag = response.data.data.returnFlag;
                        if (returnFlag == "Y") {
                            ret = true;
                        }
                    }
                }, function errorCallback(response) {
                    $.alert({
                        title: '',
                        text: '查询失败!',
                        onOK: function() {}
                    });
                });
                return ret;
            }

            /*function saveNotifyDataByPromise(param) {
            	var deferred = $q.defer();//声明承诺
            	var ret = false;
            	var returnFlag="";
            	$http({
            		method: 'GET',
            		url: app.domain + 'common/saveNotify.action',
            		params: param
            	}).then(function successCallback(response) {
            		if (response.data.success) {
            			returnFlag = response.data.data.returnFlag;
            			if(returnFlag == "Y"){
            				ret = true;
            			}
            		}
            		deferred.resolve(ret);//请求成功
            	}, function errorCallback(response) {
            		$.alert({
            			title: '',
            			text: '查询失败!',
            			onOK: function () {
            			}
            		});
            	});
            	return deferred.promise;//返回承诺
            }*/

            function stringToArray(str) {
                var tempArr = str.split(',');
                var returnArr = new Array();
                var i, len = tempArr.length;
                for (i = 0; i < len; i++) {
                    returnArr.push(tempArr[i]);
                }
                return returnArr;
            }

            /**
             * 限制只输入正整数
             */
            /*$scope.keyNumber = function(){
            	var keyCode = event.keyCode;
            	if(keyCode>=48 && keyCode<=57){
            		event.returnValue = true;
            	}else{
            		event.returnValue = false;
            	}
            }*/

            /**
             * 限制只输入正整数
             */
            /*$scope.numberVal = function(id){
            	var reg = /^\+?[1-9]\d*$/;
            	if(!reg.test($("#"+id).val())){
            		$.alert({title: '',text: '请输入大于0的正整数！',onOK: function () {}});
            		$("#"+id).val("");
            		return false;
            	}
            }*/

            /**
             * 限制只输入大于0的整数或者保留两位小数
             */
            /*$scope.keyPositive = function(id){
            	var reg=/(^[1-9]{1}[0-9]*$)|(^[0-9]*\.[0-9]{2}$)/;
            	if(!reg.test($("#"+id).val())){
            		$.alert({title: '',text: '请输入大于0的整数或者保留两位小数！',onOK: function () {}});
            		$("#"+id).val("");
            		return false;
            	}
            }*/

        }]);
})(app)